<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/Public/Login/Css/Common.css">
</head>
<body>
<div class="logo">
    <img src="/Public/Login/Images/logo.png" alt="">
    <p>258营销宝<small>绑定账号</small></p>
</div>
<div class="form mt10">
    <form id="easyForm" method="post" action="/Login/ajax_login">
        <ul>
            <input type="hidden" name="return_url" value="">
            <li class="iconfont icon-wode  confirmationBox"><input id="username" type="text" name="username" placeholder="请输入会员名/手机号/邮箱" datatype="*1-30" nullmsg="请输入会员名/手机号/邮箱">
                <div class="btn close" onclick="clearText($(this))"></div>
            </li>
            <li class="iconfont icon-yaochi confirmationBox"><input id="pwd" type="password" name="pwd" placeholder="请输入密码" datatype="*6-20" nullmsg="请输入密码" errormsg="密码由6-20个字母、数字或符号组成">
                <div class="btn iconfont icon-biyan" onclick="clickEye($(this))"></div>
            </li>
        </ul>
    </form>
</div>
<!--登陆按钮 默认加上active  填写了账号密码后移除 active-->
<input id="login" type="button" class="loginBtn Themebg mt20" value="登录">
<!--提示弹框-->
<div class="popBox"></div>
<script src="/Public/Login/Js/zepto.js"></script>
<script>
    var url = '<?=$url?>';
    //清除文字
    function clearText(obj){
        obj.parent().find('input').val("").focus();
    }
    //隐藏显示密码
    function clickEye(obj){
        if(obj.hasClass('active')){
            obj.removeClass('active');
            obj.parent().find('input').attr('type','password');
        }else{
            obj.addClass('active');
            obj.parent().find('input').attr('type','text');

        }
    }
    //提示框方法
    function show(info){
        $('.popBox').html(info);
        $('.popBox').addClass('show');
        setTimeout(function(){
            $('.popBox').html('');
            $('.popBox').removeClass('show');
        },3000)
    }
    var ajax = false;
    $('#login').click(function(){
        var username=$('#username').val();
        if(!username){
            show('请输入账号');
            return;
        }
        var pwd=$('#pwd').val();
        if(!pwd){
            show('请输入密码');
            return;
        }
        var p = $('#easyForm').serializeArray();
        if(ajax) return false;
        ajax = true;
        $.ajax({
            type: 'POST',
            url: '/Login/ajax_login',
            data: p,
            dataType: 'json',
            success: function(data){
                ajax = false;
                if(data.c==200){
                    location.href="/login/course?type="+data.d.type;
                }else{
                    show(data.m);
                }
            },
            error:function(d){
                ajax = false;
                show(d.m);
            }
        });
    });
</script>
</body>
</html>